﻿using System;
using Netkk.Common;
using Netkk.Common.Models;

namespace Netkk.Models
{
    public class AppointmentModel
    {
        public string CleanTitle { get; set; }
        public string Title { get; set; }
        public Guid Id { get; set; }
        public string ShortTitle { get; set; }
        public DateTime Date { get; set; }
        public string Description { get; set; }
        public string Location { get; set; }
        public bool ShowEditNews { get; set; }
        public string Teaser { get; set; }
        public bool ShowEditAppointments { get; set; }

        public static AppointmentModel Create()
        {
            return new AppointmentModel
            {
                Id = Guid.NewGuid(),
                Title = String.Empty,
                ShortTitle = String.Empty,
                Location = String.Empty,
                Teaser = String.Empty,
                Description = String.Empty,
                Date = DateTime.Now
            };
        }

        public static AppointmentModel Create(Appointment appointment)
        {
            return new AppointmentModel
            {
                CleanTitle = Tools.GetCleanUrl(appointment.Title),
                Title = appointment.Title,
                ShortTitle = appointment.ShortTitle,
                Location = appointment.Location,
                Description = appointment.Description,
                Teaser = appointment.Teaser,
                Date = appointment.Date,
                Id = appointment.Id
            };
        }
        public static AppointmentModel Create(Appointment appointment, bool allowEdit)
        {
            return new AppointmentModel
            {
                CleanTitle = Tools.GetCleanUrl(appointment.Title),
                Title = appointment.Title,
                ShortTitle = appointment.ShortTitle,
                Location = appointment.Location,
                Teaser = appointment.Teaser,
                Description = appointment.Description,
                Date = appointment.Date,
                Id = appointment.Id,
                ShowEditAppointments = allowEdit
            };
        }

        public Appointment MapAppointments()
        {
            return new Appointment
            {
                Id = Id,
                Title = Title,
                Date = Date,
                Teaser = Teaser,
                Location = Location,
                ShortTitle = ShortTitle,
                Description = Description
            };
        }

        public Appointment MapAppointments(Guid id)
        {
            return new Appointment
            {
                Id = id,
                Title = Title,
                Date = Date,
                Teaser = Teaser,
                Location = Location,
                ShortTitle = ShortTitle,
                Description = Description
            };
        }
    }
}
